package com.tonghl.juc.lock_study.code;

class phone{
    public synchronized  void sendSMS() throws Exception{

        System.out.println(Thread.currentThread().getName()+"\t invoked sendSMS()");
        sendEmail();
    }

    public synchronized  void sendEmail() throws Exception{
        System.out.println(Thread.currentThread().getName()+"\t invoked sendEmail()");
    }
}
/**
 * Created by tonghl
 */
public class ReentrantlockDemo {

    public static void main(String[] args) {
        phone phone = new phone();
        new Thread(()->
        {
            try{
                phone.sendSMS();
            }catch (Exception e)
            {
                e.printStackTrace();
            }
        },"t1").start();

        new Thread(()->
        {
            try{
                phone.sendEmail();
            }catch (Exception e)
            {e.printStackTrace();}
        },"t2").start();

    }


}
